home *** CD-ROM | disk | FTP | other *** search
- What is Python?
- ---------------
-
- Python is an interpreted, interactive, object-oriented programming
- language. It incorporates modules, exceptions, dynamic typing, very
- high level dynamic data types, and classes. Python combines
- remarkable power with very clear syntax. It has interfaces to many
- system calls and libraries, as well as to various window systems, and
- is extensible in C or C++. It is also usable as an extension language
- for applications that need a programmable interface. Finally, Python
- is portable: it runs on many brands of UNIX, on the Mac, and on
- MS-DOS.
-
- As a short example of what Python looks like, here's a script to
- print prime numbers (not blazingly fast, but readable!). When this
- file is made executable, it is callable directly from the UNIX shell
- (if your system supports #! in scripts and the python interpreter is
- installed at the indicated place).
-
- #!/usr/local/bin/python
-
- # Print prime numbers in a given range
-
- def main():
- import sys
- min, max = 2, 0x7fffffff
- if sys.argv[1:]:
- min = int(eval(sys.argv[1]))
- if sys.argv[2:]:
- max = int(eval(sys.argv[2]))
- primes(min, max)
-
- def primes(min, max):
- if 2 >= min: print 2
- primes = [2]
- i = 3
- while i <= max:
- for p in primes:
- if i%p == 0 or p*p > i: break
- if i%p <> 0:
- primes.append(i)
- if i >= min: print i
- i = i+2
-
- main()
-
-
-
- ------------------------------------------------------------------------
-
- Newsgroups: comp.lang.perl,comp.lang.tcl
- From: lutz@xvt.com (Mark Lutz)
- Subject: Python (was Re: Has anyone done a tk addition to perl?)
- Organization: XVT Software Inc.
- Date: Thu, 14 Oct 1993 17:10:37 GMT
- X-Disclaimer: The views expressed in this message are those of an
- individual at XVT Software Inc., and do not necessarily
- reflect those of the company.
-
-
- I've gotten a number of requests for information about Python,
- since my post here earlier this week. Since this appears to be
- of general interest, and since there's no python news group yet,
- I'm posting a description here. I'm not the best authority on
- the language, but here's my take on it.
-
- [TCL/Perl zealots: this is informational only; I'm not trying to
- 'convert' anybody, and don't have time for a language war :-)
- There is a paper comparing TCL/Perl/Python/Emacs-Lisp, which is
- referenced in the comp.lang.misc faq, I beleive.]
-
-
- What is Python?...
-
- Python is a relatively new very-high-level language developed
- in Amsterdam. Python is a simple, procedural language, with
- features taken from ABC, Icon, Modula-3, and C/C++.
-
- It's central goal is to provide the best of both worlds:
- the dynamic nature of scripting languages like Perl/TCL/REXX,
- but also support for general programming found in the more
- traditional languages like Icon, C, Modula,...
-
- As such, it can function as a scripting/extension language,
- as a rapid prototyping language, and as a serious software
- development language. Python is suitable for fast development
- of large programs, but also does well at throw-away shell coding.
-
- Python resembles other scripting languages a number of ways:
- - dynamic, interpretive, interactive nature
- - no explicit compile or link steps needed
- - no type declarations (it's dynamically typed)
- - high-level operators ('in', concatenation, etc)
- - automatic memory allocation/deallocation (no 'pointers')
- - high level objects: lists, tuples, strings, associative arrays
- - programs can construct and execute program code using strings
- - very fast edit/compile/run cycle; no static linking
- - well-defined interface to and from C functions and data
- - well-defined ways to add C modules to the system and language
-
- Python's features that make it useful for serious programming:
- - it's object-oriented; it has a simplified subset of
- C++'s 'class' facility, made more useful by python's
- dynamic typing; the language is object-oriented from
- the ground up (rather than being an add-on, as in C++)
-
- - it supports modules (imported packages, as in Modula-3);
- modules replace C's 'include' files and linking, and allow
- for multiple-module systems, code sharing, etc.;
-
- - it has a good exception handling system (a 'try' statement,
- and a 'raise' statement, with user-defined exceptions);
-
- - it's orthogonal; everything is a first-class object in the
- language (functions, modules, classes, class instance methods...)
- and can be assigned/passed and used generically;
-
- - it's fairly run-time secure; it does many run-time checks
- like index-out-of-bounds, etc., that C usually doesn't;
-
- - it has general data structuring support; Python lists are
- heterogeneous, variable length, nestable, support slicing,
- concatenation, etc., and come into existance and are reclaimed
- automatically; strings and dictionaries are similarly general;
-
- - it's got a symbolic debugger and profiler (written in python,
- of course..), and an interactive command-line interface;
- as in Lisp, you can enter code and test functions in isolation,
- from the interactive command line (even linked C functions);
-
- - it has a large library of built-in modules; it has support
- for sockets, regular expressions, posix bindings, etc.
-
- - it supports dynamic loading of C modules on many platforms;
-
- - it has a _readable_ syntax; python code looks like normal
- programming languages; tcl and perl can be very unreadable
- (IMHO; what was that joke about Perl looking the same after
- rot13..); python's syntax is simple, and statement based;
-
-
- Of course, Python isn't perfect, but it's a good compromise betweem
- scripting languages and traditional ones, and so is widely applicable.
- 'Perfect' languages aren't always useful for real-world tasks (Prolog,
- for example), and languages at either extreme are not useful in the other
- domain (C is poor for shell coding and prototyping, and awk is useless
- for large systems design; Python does both well).
-
- For example, I've used Python successfully for a 4K line expert system
- shell project; it would have been at least twice as large in C, and would
- have been very difficult in TCL or Perl.
-
- Python uses an indentation-based syntax which may seem unusual at first
- to C coders, but after using it I have found it to be _very_ handy, since
- there's less to type. [I now forget to type '}' in my C code, and am
- busy calculating how much time I wasted typing all those '}', 'END', etc.,
- just to pander to 'brain-dead' C/Pascal compilers :-)].
-
- Python's currently at release 0.9.9. It seems suprisingly stable.
- The first 'official' 1.0 release is due out by the end of this year.
- Python runs on most popular machines/systems (mac, dos, unix, etc.)
- It's public domain and distributable, and can be had via ftp. The
- distribution includes examples, tutorials, and documentation. The
- latest ftp address I have (I got it on a cd-rom):
- pub/python/* at ftp.cwi.nl
- pub/? at wuarchive.wustl.edu (in america)
-
- There's a python mailing list maintained by the language's creator.
- Mail 'python-list-request@cwi.nl' to get on it.
-
- Mark Lutz
- lutz@xvt.com
-
-
- ------------------------------------------------------------------------------
-
- Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.c++,comp.lang.perl,comp.lang.tcl
- Followup-to: comp.lang.misc
- Subject: Python 1.0.0 is out!
-
- --> Tired of decyphering the Perl code you wrote last week?
-
- --> Frustrated with Bourne shell syntax?
-
- --> Spent too much time staring at core dumps lately?
-
- Maybe you should try Python, the next generation object-oriented
- scripting and prototyping language, with a *readable* syntax. Python
- has been used by hundreds of happy users all over the world during the
- past three years, and is now ready for prime time.
-
- Python is an interpreted language, and has the usual advantages of
- such languages, such as run-time checks (e.g. bounds checking),
- execution of dynamically generated code, automatic memory allocation,
- high level operations on strings, lists and dictionaries (associative
- arrays), and a fast edit-compile-run cycle. Additionally, it features
- modules, classes, exceptions, and dynamic linking of extensions
- written in C or C++. It has arbitrary precision integers.
-
- Python can be run interactively, and there is an extensive Emacs
- editing mode which includes the capability to execute regions of code.
- For the truly desperate there is a source level debugger (written in
- Python, of course :-).
-
- Python comes with a large library of standard modules and classes, as
- well as an extensive set of demo programs. It has interfaces to most
- Unix system calls and library functions, and there exist extensions
- that interface to window systems and graphics libraries like X and
- SGI's GL.
-
- Python's source (in C) and documentation (in LaTeX and PostScript) are
- freely available on the Internet. It builds without intervention on
- most Unix platforms: error-free builds have been confirmed for SGI
- IRIX 4 and 5, Sun SunOS 4 and Solaris 2, HP-UX, DEC Ultrix and OSF/1,
- IBM AIX, and SCO ODT 3.0. A Macintosh binary is also available -- a
- DOS binary is in the works.
-
- If you have a WWW viewer (e.g. Mosaic), you can see all Python
- documentation on-line: point your viewer at the URL
- http://www.cwi.nl/~guido/Python.html.
-
- The source and documentation are available by anonymous ftp from the
- following sites -- please pick the one closest to you:
-
- Site IP address Directory
-
- ftp.cwi.nl 192.16.184.180 /pub/python
- gatekeeper.dec.com 16.1.0.2 /pub/plan/python/cwi
- ftp.uu.net 192.48.96.9 /languages/python
- ftp.fu-berlin.de 130.133.4.50 /pub/unix/languages/python
-
- The file is called python1.0.0.tar.Z (some mirror sites convert it to
- a .gz file or split it up in separate parts). See the INDEX file for
- other goodies: FAQ, NEWS, PostScript, Emacs info, Mac binary, etc.
- (Please don't ask me to mail it to you -- at 1.76 Megabytes it is
- unwieldy at least...)
-
- There's a mailing list; write to <python-list@cwi.nl> to subscribe (no
- LISTSERV commands please). A FAQ list is regularly posted to
- comp.lang.misc. A newsgroup may be created in the near future.
-
- [Excuse the hype -- Python really is a neat language, if I may say so.
- Please direct all followups to comp.lang.misc only.]
-
- --Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
- URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
-